package ddd;
import ddd.constant.PlayerEnum;

/**
 * @author dengzhiyuan
 * @version 1.0
 * @time 2021/5/24 15:45
 */
public class Player{

    private Player playerId;
    private String name;
    private PlayerEnum playerClass;
    private Weapon weaponId;
    private Transform position = Transform.ORIGIN;
    private Vector velocity = Vector.ZERO;
    private int exp;


    public Player(String name, PlayerEnum playerClass) {
        this.name = name;
        this.playerClass = playerClass;
        this.playerId =this;
    }

    public void equip(Weapon weapon, EquipmentService equipmentService) {
        if (equipmentService.canEquip(this, weapon)) {
            this.weaponId = weapon;
        } else {
            throw new IllegalArgumentException("Cannot Equip: " + weapon);
        }
    }

    public void setPlayerId(Player playerId) {
        this.playerId = playerId;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPlayerClass(PlayerEnum playerClass) {
        this.playerClass = playerClass;
    }

    public void setWeaponId(Weapon weaponId) {
        this.weaponId = weaponId;
    }

    public Player getPlayerId() {
        return playerId;
    }

    public String getName() {
        return name;
    }

    public PlayerEnum getPlayerClass() {
        return playerClass;
    }

    public Weapon getWeaponId() {
        return weaponId;
    }

    /**
     * 接收经验
     * @param value
     */
    public void receiveExp(int value) {
        this.exp += value;
        if (this.exp >= 100) {
//            LevelUpEvent event = new LevelUpEvent(this);
//            EventBus.dispatch(event);
//            this.exp = 0;
        }
    }

    /**
     * 是否可以升级
     * @return
     */
    public boolean canLevelUp() {
        return true;
    }

    /**
     * 升级
     */
    public void levelUp() {

    }
}


